﻿using System;
using UnityEngine;

namespace XFramework
{

    /// <summary>
    /// Item基类
    /// </summary>
    public class MonoItem : MonoBehaviour
    {
        private int _id = -1;

        public virtual int Id
        {
            get { return _id; }
            set { _id = value; }
        }

        protected object _data = null;

        public virtual bool IsActive { get; private set; } = false;


        public virtual void InitData(object data)
        {
            this._data = data;
        }

        public virtual MonoItem SetActive(bool isActive)
        {
            IsActive = isActive;
            gameObject.SetActive(isActive);

            return this;
        }

        protected virtual void OnDestroy()
        {
            this.Id = -1;
            this.IsActive = false;
            _data = null;
        }
    }

}